﻿using DevExpress.XtraGrid.Views.Grid;
using RecruitStudents.Client.BLL;
using RecruitStudents.Client.Loading;
using RecruitStudents.Utility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client.Base
{
    public partial class Base_Mac_List : BaseForm
    {
        ServiceBase service = new ServiceBase();
        public Base_Mac_List()
        {
            InitializeComponent();
            BindData();
        }
        private void BindData()
        {
            DataTable dt = null;
            dt = service.GetExamMacTable(this.chkSFTY.Checked, txtMac.Text);
            dgMac.DataSource = dt;
        }

        private void benQuery_Click(object sender, EventArgs e)
        {
            BindData();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            Base_Mac_Option option = new Base_Mac_Option(string.Empty);
            if (option.ShowDialog() == DialogResult.OK)
            {
                this.BindData();
            }
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            GridView rows = sender as GridView;
            int[] inteurm = rows.GetSelectedRows();
            if (inteurm != null && inteurm.Length > 0)
            {
                string strMacID = rows.Rows[inteurm[0]].DataRow["MacID"].ToSafeString();
                Base_Mac_Option option = new Base_Mac_Option(strMacID);
                if (option.ShowDialog() == DialogResult.OK)
                {
                    this.BindData();
                }
            }
        }
    }
}
